import request from "@/utils/request";
/* 采购单列表
 * @param { getProcureList } data
 */
export const getProcureList = data => {
  return request({
    url: "/mall/tenant/merchant/purchase/order/page",
    method: "post",
    data
  });
};
/* 采购单列表
 * @param { listByTenantId } data
 */
export const listByTenantId = () => {
  return request({
    url: "/mall/tenant/merchant/warehouse/listByTenantId",
    method: "get"
  });
};
/* 获取创建人
 * @param { getCreateInfoList } data
 */
export const getCreateInfoList = () => {
  return request({
    url: "/mall/tenant/merchant/purchase/order/getCreateInfoList",
    method: "get"
  });
};
/* 关闭采购单
 * @param { closPurchaseOrderId } data
 */
export const closPurchaseOrderId = purchaseOrderId => {
  return request({
    url: `/mall/tenant/merchant/purchase/order/close/${purchaseOrderId}`,
    method: "post"
  });
};
/* 采购清单
 * @param { getPurchaseOrderId }
 */
export const getPurchaseOrderId = purchaseOrderId => {
  return request({
    url: `/mall/tenant/merchant/purchase/order/${purchaseOrderId}/detail`,
    method: "get"
  });
};
/* 获取供应商列表
 * @param { getProvideList }
 */
export const getProvideList = (data, size, current) => {
  return request({
    url: `/mall/tenant/merchant/tenant/getProvideList?size=${size}&current=${current}`,
    method: "post",
    data
  });
};
/* 获取供应商列表
 * @param { getSuppliers }
 */
export const getSuppliers = data => {
  return request({
    url: "/mall/tenant/merchant/product/getSuppliers",
    method: "post",
    data
  });
}; /* 获取供应商信息
 * @param { getFactoryInfo }
 */
export const getFactoryInfo = factoryId => {
  return request({
    url: `/mall/tenant/factory/info/getFactoryInfo/${factoryId}`,
    method: "get"
  });
};
/* 商品列表
 * @param { getBusinessListings }
 */
export const getBusinessListings = data => {
  return request({
    url: "/mall/tenant/merchant/product/pageByKeyword",
    method: "post",
    data
  });
};
/* 获取商品详情
 * @param { getDetail }
 */
export const getDetail = data => {
  return request({
    url: "/mall/shopHome/product",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data"
    },
    data
  });
};

/* 获取采购单详情
 * @param { purchaseOrderId }
 */
export const purchaseOrderId = purchaseOrderId => {
  return request({
    // url: `/mall/tenant/merchant/purchase/order/${purchaseOrderId}/detail`,
    url: `/mall/tenant/merchant/purchase/order/${purchaseOrderId}/new/detail`,
    method: "get"
  });
};

/* 获取收货仓库信息
 * @param { getlistByTenantId }
 */
export const getlistByTenantId = () => {
  return request({
    url: "/mall/tenant/merchant/warehouse/listByTenantId",
    method: "get"
  });
};

/* 保存临时接口
 * @param { saveTempProduct }
 */
export const saveTempProduct = data => {
  return request({
    url: "/mall/tenant/merchant/inboundOrder/saveTempProduct",
    method: "post",
    data
  });
};

/* 获取临时采购商品
 * @param { getTempProductSkuList }
 */
export const getTempProductSkuList = data => {
  return request({
    url: "/mall/tenant/merchant/inboundOrder/getTempProductSkuList",
    method: "post",
    data
  });
};
//

/* 创建采购单
 * @param { createSubmit }
 */
export const createSubmit = data => {
  return request({
    url: "/mall/tenant/merchant/independent/purchase/order/submit",
    method: "post",
    data
  });
};
/* 删除临时采购单
 * @param { delTempProductSku }
 */
export const delTempProductSku = data => {
  return request({
    url: "/mall/tenant/merchant/inboundOrder/delTempProductSku",
    method: "post",
    data
  });
};
/* 保存独立采购单
 * @param { savePurchaseOrder }
 */
export const savePurchaseOrder = data => {
  return request({
    url: "/mall/tenant/merchant/independent/purchase/order/save",
    method: "post",
    data
  });
};
/* 关闭订单
 * @param { closeOder }
 */
export const closeOder = purchaseOrderId => {
  return request({
    url: `/mall/tenant/merchant/independent/purchase/order/close/${purchaseOrderId}`,
    method: "post"
  });
};

/* 拒绝重新提交采购单
 * @param { resubmit }
 */
export const resubmit = data => {
  return request({
    url: "/mall/tenant/merchant/purchase/order/resubmit",
    method: "post",
    data
  });
};

/* 删除已关闭的采购单
 * @param { deleteClose }
 */
export const deleteClose = purchaseOrderId => {
  return request({
    url: `/mall/tenant/merchant/purchase/order/delete/${purchaseOrderId}`,
    method: "post"
  });
};

/**
 * 修改本次应付金额
 */
export const updateCurrentAmount = props => {
  return request({
    url: "/mall/tenant/merchant/purchase/order/updateCurrentAmount",
    method: "post",
    data: props
  });
};
/**
 * 撤销采购单
 */
export const cancelOrder = props => {
  return request({
    url: `/mall/tenant/merchant/purchase/order/cancel/${props.purchaseOrderId}`,
    method: "post"
  });
};

/**
 * 获取完成确认信息
 */
export const getFinishConfirm = props => {
  return request({
    url: "/mall/tenant/merchant/purchase/order/getFinishConfirm",
    method: "post",
    data: props
  });
};

/**
 * 提交完成确认信息
 */
export const commitConfirm = props => {
  return request({
    url: "/mall/tenant/merchant/purchase/order/commitConfirm",
    method: "post",
    data: props
  });
};

/**
 * 获取预计发货时间信息
 */
export const getShipmentDaysByProducts = props => {
  return request({
    url: "/mall/tenant/merchant/order/getShipmentDaysByProducts",
    method: "post",
    data: props
  });
};

/**
 * 采购单导出
 */
export const cgOrderDownload = props => {
  return request({
    url: "/mall/tenant/merchant/purchase/order/download",
    method: "post",
    responseType: "blob",
    data: props
  });
};
